package com.example.demo.pojo.store;

import com.example.demo.pojo.vo.QuestionVO;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class BankStore {
   private List<QuestionVO>questionVOList;
    public void updateList(List<QuestionVO>questionVOList){
        this.questionVOList=questionVOList;
    }
    public List<QuestionVO> queryPage(int index,int pageSize){
        if(this.questionVOList==null){
            return null;
        }
        int totalNumber=questionVOList.size();
        int firstIndex=(index-1)*pageSize;
        int lastIndex=(index)*pageSize;
        if(lastIndex>totalNumber){
            lastIndex=totalNumber;
        }
        List<QuestionVO>result=new ArrayList<QuestionVO>();
        for(int i=firstIndex;i<lastIndex;i++){
            this.questionVOList.get(i).setId(i+1);
            result.add(this.questionVOList.get(i));
        }
        return result;
    }
}

